﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using WarOfDev.EF;

namespace WarOfDev.Services.Developer
{
    public class DeveloperService
    {
        private static WarDevEntities db = new EF.WarDevEntities();
        

        public static IEnumerable<SelectListItem> GetAllDeveloperList(string selectedDeveloperId)
        {
            var query = from developer in db.Developers
                        where !developer.IsLocked
                        select new SelectListItem
                        {
                            Selected = developer.Id == selectedDeveloperId,
                            Text = developer.NickName,
                            Value = developer.Id
                        };

            var ret = query.ToList();
            ret.Add(new SelectListItem 
            { 
                Value="-1",
                Text="Pending",
                Selected=string.IsNullOrEmpty(selectedDeveloperId) || selectedDeveloperId=="-1"
            }
            );

            return ret;
        }
    }
}
